import redis
from flask import current_app

class RedisOper():
    def __init__(self):
        host = current_app.config.get('REDIS_HOST')
        port = current_app.config.get('REDIS_PORT')
        db = current_app.config.get('REDIS_DB')
        password = current_app.config.get('REDIS_PASSWORD')

        self.rds = redis.Redis(host=host,port=port,db=db,password=password)

    # 存redis
    def set_v(self, data, value,ex):
        self.rds.set("data_%s"%data, value,ex)


    # 取redis
    def get_v(self, data):
        return  self.rds.get("data_%s"%data)





